package gs.android.bingomathfree;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class TaskActivity extends Activity {
	private Button plus, minus, times, divide, equations;
	
	@Override
	public void onCreate(Bundle savedInstance) {
		super.onCreate(savedInstance);
		setContentView(R.layout.task);
		
		plus = (Button) findViewById(R.id.btnPlus);
		plus.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent intent = new Intent(v.getContext(), BingoActivity.class);
				intent.putExtra("task", BingoActivity.PLUS);
				startActivityForResult(intent, 1);
			}
		});
		
		minus = (Button) findViewById(R.id.btnMinus);
		minus.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent intent = new Intent(v.getContext(), BingoActivity.class);
				intent.putExtra("task", BingoActivity.MINUS);
				startActivityForResult(intent, 1);
			}
		});
		
		times = (Button) findViewById(R.id.btnTimes);
		times.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent intent = new Intent(v.getContext(), BingoActivity.class);
				intent.putExtra("task", BingoActivity.TIMES);
				startActivityForResult(intent, 1);
			}
		});
		
		divide = (Button) findViewById(R.id.btnDivide);
		divide.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent intent = new Intent(v.getContext(), BingoActivity.class);
				intent.putExtra("task", BingoActivity.DIVIDE);
				startActivityForResult(intent, 1);
			}
		});
		
		equations = (Button) findViewById(R.id.btnEquations);
		equations.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent intent = new Intent(v.getContext(), BingoActivity.class);
				intent.putExtra("task", BingoActivity.EQUATIONS);
				startActivityForResult(intent, 1);
			}
		});
	}
	
	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		super.onActivityResult(requestCode, resultCode, data);
		if (requestCode == 1 && resultCode == RESULT_OK) {
			RateDialog d = new RateDialog(this);
			d.show();
		} else {
			DialogAds d = new DialogAds(this);
			d.show();
		}
	}
}
